package training.list.refimpl;

import training.list.ListNode;
import training.list.ReverseList;

public class ReverseListSolution implements ReverseList {

    public ListNode reverse(ListNode pHead) {
        ListNode prev = null;
        ListNode cur = pHead;

        while (cur != null) {
            ListNode temp = cur.next;
            cur.next = prev;
            prev = cur;
            cur = temp;
        }

        return prev;
    }

}
